import animatepath from "./animatepath"
import lgxcom from '../common/common.js'
import utilfuncs from "../common/tools/utilfuncs";
var funcs = utilfuncs.UtilFuncs;


class RotatePath extends animatepath.AnimatePath {
    constructor(pt,rotPathGraph) {
        super();
        this.type = "obj";
        this.pathDesc = rotPathGraph;
        this.rotCnt = {x:pt.x,y:pt.y};
        this.relate2PathPt = {x:0,y:0};
        if (rotPathGraph){
            let pathCnt = rotPathGraph.getPosCopy().getCnt();
            this.relate2PathPt.x = pt.x - pathCnt.x;
            this.relate2PathPt.y = pt.y - pathCnt.y;
        }
    }
    animate(speed) {
        let cntPt = {x:0,y:0};
        if (this.pathDesc){
            let pathCnt = this.pathDesc.getPosCopy().getCnt();
            cntPt.x = pathCnt.x + this.relate2PathPt.x;
            cntPt.y = pathCnt.y + this.relate2PathPt.y;
        }
        else{
            cntPt.x = this.rotCnt.x;
            cntPt.y = this.rotCnt.y;
        }
        return { rotPt:cntPt, angle:speed };
    }
}

export default { RotatePath }